# spatial lag model
model1_strikes_slm <- lagsarlm(f1, data=shape_strikes, lw_strikes, tol.solve=1.0e-30)
summary(model1_strikes_ols)
summary(model1_strikes_sem)
summary(model1_strikes_slm)
# Impute missing sabotage with mean
shape_sabotage <- shape %>%
mutate(sabotage = ifelse(is.na(sabotage), mean(sabotage, na.rm=TRUE), sabotage))
# create adjacency matrix
nb_sabotage <- poly2nb(shape_sabotage, row.names = shape_sabotage$gmina)
# This creates the adjacency matrix; here we use a binary matrix ('style="B"')
# We could also row-standardize ('style="W"') d rather than a weighted matrix
lw_sabotage <- nb2listw(nb_sabotage, zero.policy=TRUE, style="B" )
# formulas
f1 <- scale(sabotage) ~ m_commander_1945_86 + factor(woj)
# basic OLS model
model1_sabotage_ols <- lm(f1, data = shape_sabotage)
# spatial error model
model1_sabotage_sem <- errorsarlm(f1, data=shape_sabotage, lw_sabotage, tol.solve=1.0e-30, zero.policy = T)
# spatial lag model
model1_sabotage_slm <- lagsarlm(f1, data=shape_sabotage, lw_sabotage, tol.solve=1.0e-30)
summary(model1_sabotage_ols)
summary(model1_sabotage_sem)
summary(model1_sabotage_slm)
rm(list =ls())
options(scipen=999)
gc()
packages <-c("tidyverse","estimatr","plm","stargazer",
"fastDummies","ICCbin","ihs","readstata13","xtable")
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(packages, require, character.only = TRUE)
rm(packages)
data <- read.csv("./Datasets/main_confounders.csv")
data <- data%>%
dplyr::mutate(across(subbotnik_inkind_1975:subbotnik_inkind_1979, ~scale(.x)))%>%
dplyr::rowwise()%>%
dplyr::mutate(compliance = mean(c(subbotnik_inkind_1975, subbotnik_inkind_1976,
subbotnik_inkind_1977, subbotnik_inkind_1978,
subbotnik_inkind_1979), na.rm = TRUE))%>%
dplyr::ungroup()%>%
dplyr::mutate(commander_1975_86 = scale(commander_1975_86),
strikes = scale(strikes),
sabotage = scale(compliance * -1))
lm_strikes <- lm(strikes ~ commander_1975_86 + arrests, data = data)
lm_sabotage <- lm(sabotage ~ commander_1975_86 + arrests, data = data)
stargazer(lm_strikes, lm_sabotage,
dep.var.labels = c("Protests", "Sabotage"),
style = "qje",
covariate.labels = c("Surveillance","Arrests"),
star.char = c("*", "**", "***"),
star.cutoffs = c(0.1, 0.05, 0.01),
omit = c("Constant", "factor"),
omit.stat = c("rsq", "f", "ser"),
omit.table.layout = "n",
add.lines = list(c("Fixed effects", "No", "No"),
c("Controls", "No", "No")),
out = "PUT YOUR FILEPATH HERE")
stargazer(lm_strikes, lm_sabotage,
title = "Table A10: Effect of surveillance on resistance (controlling for arrests)",
dep.var.labels = c("Protests", "Sabotage"),
style = "qje",
covariate.labels = c("Surveillance","Arrests"),
star.char = c("*", "**", "***"),
star.cutoffs = c(0.1, 0.05, 0.01),
omit = c("Constant", "factor"),
omit.stat = c("rsq", "f", "ser"),
omit.table.layout = "n",
add.lines = list(c("Fixed effects", "No", "No"),
c("Controls", "No", "No")),
out = "PUT YOUR FILEPATH HERE")
rm(list =ls())
options(scipen=999)
gc()
packages <-c("tidyverse","estimatr","plm","stargazer",
"fastDummies","ICCbin","ihs","readstata13","xtable",
"arm")
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(packages, require, character.only = TRUE)
rm(packages)
## insheet data
data <- read.csv("./Datasets/panel_bare_bones.csv")
## clean data
data$X <- NULL
data$locality_year <- NULL
data$subbotnik_inkind <- NULL
data$locality <- as.character(tolower(data$locality))
# insheet covariates
data <- merge(data, read.csv("./Datasets/main_confounders.csv")[,c("locality", "region", "pop", "schools", "shops", "restaurants", "cinemas", "Frac48", "coal_sqm", "minerals", "partition", "priests_continuous")], by = c("locality"), all.x = T)
data$region <- as.numeric(as.factor(data$region))
# subset to years with observations:
data_t <- data[which(data$year>1974 & data$year<1980),]
# create wealth index
data_t$shops <- scale(data_t$shops)
data_t$restaurants <- scale(data_t$restaurants)
data_t$cinemas <- scale(data_t$cinemas)
data_t$wealth_index <- rowSums(data_t[,c("shops","restaurants","cinemas")], na.rm = T)
head(data_t[,c("shops", "restaurants", "cinemas", "wealth_index")], 50)
data_t$wealth_index[data_t$wealth_index == "NaN"] = NA
data_t$wealth_index <- scale(data_t$wealth_index)
# create state capacity index
data_t$state_capacity_index <- scale(data_t$schools)
# create ethnic diversity index
data_t$ethnic_diversity_index <- scale(data_t$Frac48)
# create Russian occupation index
data_t$Russian_occupation_index <- ifelse(data_t$partition=="Russian",1,0)
data_t$Russian_occupation_index <- scale(data_t$Russian_occupation_index)
# create industrialization index
data_t$coal_sqm <- scale(data_t$coal_sqm)
data_t$minerals <- scale(data_t$minerals)
data_t$industrialization_index <- rowSums(data_t[,c("coal_sqm","minerals")], na.rm = F)
data_t$industrialization_index[data_t$industrialization_index == "NaN"] = NA
data_t$industrialization_index <- scale(data_t$industrialization_index)
# aggregate data
data_agg <- aggregate(data_t[,c("locality_numeric", "region", "commanders", "priests_continuous", "wealth_index", "state_capacity_index", "ethnic_diversity_index", "Russian_occupation_index", "industrialization_index")], by=list(Category=data_t$locality_numeric), FUN=mean, na.rm=T)
# regressions
m_first_stage_bare <- lm(commanders ~ priests_continuous, data = data_agg)
summary(m_first_stage_bare)
m_first_stage_controls <- lm(commanders ~ priests_continuous + wealth_index + state_capacity_index + ethnic_diversity_index + Russian_occupation_index + industrialization_index + region, data = data_agg)
summary(m_first_stage_controls)
# subset to years with observations:
data_t_late <- data[which(data$year>1979),]
# average across years
data_agg_late <- aggregate(data_t_late[ ,c("locality_numeric", "region", "commanders", "priests_continuous")], by=list(Category=data_t_late$locality_numeric), FUN=mean, na.rm=T)
# attach covariates from above
data_agg_late <- merge(data_agg_late, data_agg[,c("locality_numeric", "wealth_index", "state_capacity_index", "ethnic_diversity_index", "Russian_occupation_index", "industrialization_index")], by = "locality_numeric", all.x = T)
# regressions
m_first_stage_bare_late <- lm(commanders ~ priests_continuous, data = data_agg_late)
summary(m_first_stage_bare_late)
m_first_stage_controls_late <- lm(commanders ~ priests_continuous + wealth_index + state_capacity_index + ethnic_diversity_index + Russian_occupation_index + industrialization_index + region, data = data_agg_late)
summary(m_first_stage_controls_late)
stargazer(m_first_stage_bare, m_first_stage_controls, m_first_stage_bare_late, m_first_stage_controls_late,
dep.var.labels = c("Secret police officers"),
style = "qje",
covariate.labels = c("Corrupt priests", "Wealth", "State capacity", "Ethnic diversity",
"Russian occupation", "Industrialization"),
star.char = c("*", "**", "***"),
star.cutoffs = c(0.1, 0.05, 0.01),
omit = c("Constant", "factor"),
omit.stat = c("rsq", "ser"),
omit.table.layout = "n",
add.lines = list(c("Fixed effects", "No", "Yes", "No", "Yes"),
c("Controls", "No", "Yes", "No", "Yes")),
out = "PUT YOUR FILEPATH HERE")
rm(list = ls())
gc()
set.seed(63296)
packages <-c("readstata13", "raster", "stargazer", "ggplot2", "spdep",
"tseries", "rgdal", "splm", "reshape2","spatialreg")
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(packages, require, character.only = TRUE)
rm(packages)
# load community shape file
shape <- sf::st_read("./Datasets/spatial_models_data/municipalities_km.shp") %>%
mutate(gmina = tolower(gmina)) %>%
filter(woj %in% c('KA', 'CZ', 'OP', 'BB'))
# treatment
treatment <- readstata13::read.dta13("./Datasets/spatial_models_data/map.dta") %>%
dplyr::select(locality_volha, strikes, priests_continuous, subbotnik_compliance)
# treatment
treatment <- read.csv("./Datasets/spatial_models_data/map.csv") %>%
dplyr::select(locality_volha, strikes, priests_continuous, subbotnik_compliance)
# change label
treatment$strikes <- treatment$strikes
treatment$sabotage <- treatment$subbotnik_compliance
# turn sabotage upside down
treatment$sabotage <- treatment$sabotage*-1
# merge both data sets
shape = shape %>% left_join(treatment, by = c('gmina' = 'locality_volha'))
# throw out treatment data
rm(treatment)
# Restrict data to complete cases
shape_strikes <- shape %>% filter(!is.na(shape$strikes))
#create adjacency matrix
nb_strikes <- poly2nb(shape_strikes, row.names = shape_strikes$gmina)
# This creates the adjacency matrix; here we use a binary matrix ('style="B"')
# We could also row-standardize ('style="W"') d rather than a weighted matrix
lw_strikes <- nb2listw(nb_strikes, zero.policy=TRUE, style="B" )
# formulas
f1 <- scale(strikes) ~ priests_continuous + factor(woj)
# basic OLS model
model1_strikes_ols <- lm(f1, data = shape_strikes)
# spatial error model
model1_strikes_sem <- errorsarlm(f1, data=shape_strikes, lw_strikes, tol.solve=1.0e-30, zero.policy = T)
# spatial lag model
model1_strikes_slm <- lagsarlm(f1, data=shape_strikes, lw_strikes, tol.solve=1.0e-30)
summary(model1_strikes_ols)
summary(model1_strikes_sem)
summary(model1_strikes_slm)
# Impute missing sabotage with mean
shape_sabotage <- shape %>%
mutate(sabotage = ifelse(is.na(sabotage), mean(sabotage, na.rm=TRUE), sabotage))
#create adjacency matrix
nb_sabotage <- poly2nb(shape_sabotage, row.names = shape_sabotage$gmina)
# This creates the adjacency matrix; here we use a binary matrix ('style="B"')
# We could also row-standardize ('style="W"') d rather than a weighted matrix
lw_sabotage <- nb2listw(nb_sabotage, zero.policy=TRUE, style="B" )
# formulas
f1 <- scale(sabotage) ~ priests_continuous + factor(woj)
# basic OLS model
model1_sabotage_ols <- lm(f1, data = shape_sabotage)
# spatial error model
model1_sabotage_sem <- errorsarlm(f1, data=shape_sabotage, lw_sabotage, tol.solve=1.0e-30, zero.policy = T)
# spatial lag model
model1_sabotage_slm <- lagsarlm(f1, data=shape_sabotage, lw_sabotage, tol.solve=1.0e-30)
summary(model1_sabotage_ols)
summary(model1_sabotage_sem)
summary(model1_sabotage_slm)
# output regression
stargazer(model1_strikes_sem, model1_strikes_slm, model1_sabotage_sem, model1_sabotage_slm,
dep.var.labels = c("Strikes", "Sabotage"),
style = "qje",
covariate.labels = c("Corrupted priests"),
star.char = c("*", "**", "***"),
star.cutoffs = c(0.1, 0.05, 0.01),
omit = c("Constant", "factor"),
omit.stat = c("rsq", "f", "ser"),
omit.table.layout = "n",
add.lines = list(c("Fixed effects", "Yes", "Yes", "Yes", "Yes"),
c("Controls", "No", "No", "No", "No")),
out = "PUT YOUR FILEPATH HERE")
rm(list = ls())
gc()
set.seed(63296)
packages <-c("tidyverse","readstata13", "raster", "stargazer", "ggplot2", "spdep",
"tseries", "rgdal", "splm", "reshape2","spatialreg","ihs","AER")
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(packages, require, character.only = TRUE)
rm(packages)
## insheet data
data <- read.csv("./Datasets/panel_bare_bones.csv")
## clean data
data$X <- NULL
data$locality_year <- NULL
data$subbotnik_inkind <- NULL
data$locality <- as.character(tolower(data$locality))
# insheet covariates, including spy priests
data <- merge(data, read.csv("./Datasets/main_confounders.csv")[,c("locality", "region", "pop", "schools", "shops", "restaurants", "cinemas", "Frac48", "coal_sqm", "minerals", "partition", "priests_continuous", "priests_relocated","pop")], by = c("locality"), all.x = T)
data$region_numeric <- as.numeric(as.factor(data$region))
data$priests_continuous <- data$priests_relocated
#subset to years with observations:
data_t <- data[which(data$year<1980),]
# turn sabotage upside down
data_t$subbotnik_inkind_ <- data_t$subbotnik_inkind_*-1
# create wealth index
data_t$shops <- scale(data_t$shops)
data_t$restaurants <- scale(data_t$restaurants)
data_t$cinemas <- scale(data_t$cinemas)
data_t$wealth_index <- rowSums(data_t[,c("shops","restaurants","cinemas")], na.rm = T)
head(data_t[,c("shops", "restaurants", "cinemas", "wealth_index")], 50)
data_t$wealth_index[data_t$wealth_index == "NaN"] = NA
data_t$wealth_index <- scale(data_t$wealth_index)
# create state capacity index
data_t$state_capacity_index <- scale(data_t$schools)
# create ethnic diversity index
data_t$ethnic_diversity_index <- scale(data_t$Frac48)
# create Russian occupation index
data_t$Russian_occupation_index <- ifelse(data_t$partition=="Russian",1,0)
data_t$Russian_occupation_index <- scale(data_t$Russian_occupation_index)
# create industrialization index
data_t$coal_sqm <- scale(data_t$coal_sqm)
data_t$minerals <- scale(data_t$minerals)
data_t$industrialization_index <- rowSums(data_t[,c("coal_sqm","minerals")], na.rm = F)
data_t$industrialization_index[data_t$industrialization_index == "NaN"] = NA
data_t$industrialization_index <- scale(data_t$industrialization_index)
var <- c("locality_numeric", "subbotnik_inkind_", "commanders",
"priests_continuous", "pop", "region_numeric", "wealth_index",
"state_capacity_index", "ethnic_diversity_index", "Russian_occupation_index",
"industrialization_index")
# average over years
data_agg <- aggregate(data_t[,c("locality_numeric", "subbotnik_inkind_", "commanders",
"priests_continuous", "pop", "region_numeric", "wealth_index",
"state_capacity_index", "ethnic_diversity_index", "Russian_occupation_index",
"industrialization_index")], by=list(Category=data_t$locality_numeric), FUN=mean, na.rm=T)
# regressions
model_sabotage_bare = ivreg(scale(subbotnik_inkind_) ~ commanders | priests_continuous, data = data_agg)
model_sabotage_ctrl = ivreg(scale(subbotnik_inkind_) ~ commanders | priests_continuous + wealth_index + state_capacity_index + ethnic_diversity_index + Russian_occupation_index + industrialization_index + factor(region_numeric), data = data_agg)
summary(model_sabotage_bare)
summary(model_sabotage_ctrl)
# subset to years with observations:
data_t_late <- data[which(data$year>1979),]
# average across years
data_agg_late <- aggregate(data_t_late[,c("locality_numeric", "strikes", "commanders", "priests_continuous", "region_numeric")], by=list(Category=data_t_late$locality_numeric), FUN=mean, na.rm=T)
# attach covariates from above
data_agg_late <- merge(data_agg_late, data_agg[,c("pop", "locality_numeric", "wealth_index", "state_capacity_index", "ethnic_diversity_index", "Russian_occupation_index", "industrialization_index")], by = "locality_numeric", all.x = T)
# regressions
model_strikes_bare = ivreg(scale(strikes) ~ commanders | priests_continuous, data = data_agg_late)
model_strikes_ctrl = ivreg(scale(strikes) ~ commanders | priests_continuous + pop + wealth_index + state_capacity_index + ethnic_diversity_index + Russian_occupation_index + industrialization_index + factor(region_numeric), data = data_agg_late)
summary(model_strikes_bare)
summary(model_strikes_ctrl)
stargazer(model_sabotage_bare, model_sabotage_ctrl, model_strikes_bare, model_strikes_ctrl,
dep.var.labels = c("Sabotage", "Protests"),
style = "qje",
covariate.labels = c("Commanders"),
star.char = c("*", "**", "***"),
star.cutoffs = c(0.1, 0.05, 0.01),
omit = c("Constant"),
omit.stat = c("rsq", "ser"),
omit.table.layout = "n",
add.lines = list(c("Controls", "No", "Yes", "No", "Yes"),
c("FEs", "No", "Yes", "No", "Yes")),
out = "PUT YOUR FILEPATH HERE")
rm(list = ls())
gc()
set.seed(63296)
packages <-c("tidyverse","readstata13", "raster", "stargazer", "ggplot2", "spdep",
"tseries", "rgdal", "splm", "reshape2","spatialreg","ihs","AER")
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(packages, require, character.only = TRUE)
rm(packages)
## insheet data
data <- read.csv("./Datasets/panel_bare_bones.csv")
## clean data
data$X <- NULL
data$locality_year <- NULL
data$subbotnik_inkind <- NULL
data$locality <- as.character(tolower(data$locality))
# insheet covariates, including spy priests
data <- merge(data, read.csv("./Datasets/main_confounders.csv")[,c("locality", "region", "pop", "schools", "shops", "restaurants", "cinemas", "Frac48", "coal_sqm", "minerals", "partition", "priests_continuous", "priests_relocated", "pop")], by = c("locality"), all.x = T)
data$region_numeric <- as.numeric(data$region)
data <- read.csv("./Datasets/panel_bare_bones.csv")
## clean data
data$X <- NULL
data$locality_year <- NULL
data$subbotnik_inkind <- NULL
data$locality <- as.character(tolower(data$locality))
# insheet covariates, including spy priests
data <- merge(data, read.csv("./Datasets/main_confounders.csv")[,c("locality", "region", "pop", "schools", "shops", "restaurants", "cinemas", "Frac48", "coal_sqm", "minerals", "partition", "priests_continuous", "priests_relocated", "pop")], by = c("locality"), all.x = T)
data$region_numeric <- as.numeric(as.factor(data$region))
data$priests_continuous <- data$priests_relocated
#subset to years with observations:
data_t <- data[which(data$year<1980),]
# turn sabotage upside down
data_t$subbotnik_inkind_ <- data_t$subbotnik_inkind_*-1
# create wealth index
data_t$shops <- scale(data_t$shops)
data_t$restaurants <- scale(data_t$restaurants)
data_t$cinemas <- scale(data_t$cinemas)
data_t$wealth_index <- rowSums(data_t[,c("shops","restaurants","cinemas")], na.rm = T)
head(data_t[,c("shops", "restaurants", "cinemas", "wealth_index")], 50)
data_t$wealth_index[data_t$wealth_index == "NaN"] = NA
data_t$wealth_index <- scale(data_t$wealth_index)
# create state capacity index
data_t$state_capacity_index <- scale(data_t$schools)
# create ethnic diversity index
data_t$ethnic_diversity_index <- scale(data_t$Frac48)
# create Russian occupation index
data_t$Russian_occupation_index <- ifelse(data_t$partition=="Russian",1,0)
data_t$Russian_occupation_index <- scale(data_t$Russian_occupation_index)
# create industrialization index
data_t$coal_sqm <- scale(data_t$coal_sqm)
data_t$minerals <- scale(data_t$minerals)
data_t$industrialization_index <- rowSums(data_t[,c("coal_sqm","minerals")], na.rm = F)
data_t$industrialization_index[data_t$industrialization_index == "NaN"] = NA
data_t$industrialization_index <- scale(data_t$industrialization_index)
# average over years
data_agg <- aggregate(data_t[,c("locality_numeric", "subbotnik_inkind_", "commanders",
"priests_continuous", "pop", "region_numeric", "wealth_index",
"state_capacity_index", "ethnic_diversity_index", "Russian_occupation_index",
"industrialization_index")], by=list(Category=data_t$locality_numeric), FUN=mean, na.rm=T)
# regressions
model_sabotage_bare = ivreg(scale(subbotnik_inkind_) ~ commanders | priests_continuous, data = data_agg)
model_sabotage_ctrl = ivreg(scale(subbotnik_inkind_) ~ commanders | priests_continuous + wealth_index + state_capacity_index + ethnic_diversity_index + Russian_occupation_index + industrialization_index + factor(region_numeric), data = data_agg)
summary(model_sabotage_bare)
summary(model_sabotage_ctrl)
# subset to years with observations:
data_t_late <- data[which(data$year>1979),]
# average across years
data_agg_late <- aggregate(data_t_late[,c("locality_numeric", "strikes", "commanders", "priests_continuous", "region_numeric")], by=list(Category=data_t_late$locality_numeric), FUN=mean, na.rm=T)
# attach covariates from above
data_agg_late <- merge(data_agg_late, data_agg[,c("pop", "locality_numeric", "wealth_index", "state_capacity_index", "ethnic_diversity_index", "Russian_occupation_index", "industrialization_index")], by = "locality_numeric", all.x = T)
# regressions
model_strikes_bare = ivreg(scale(strikes) ~ commanders | priests_continuous, data = data_agg_late)
model_strikes_ctrl = ivreg(scale(strikes) ~ commanders | priests_continuous + pop + wealth_index + state_capacity_index + ethnic_diversity_index + Russian_occupation_index + industrialization_index + factor(region_numeric), data = data_agg_late)
summary(model_strikes_bare)
summary(model_strikes_ctrl)
rm(list = ls())
gc()
set.seed(63296)
packages <-c("readstata13","ggplot2")
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(packages, require, character.only = TRUE)
rm(packages)
## insheet data
data <- read.csv("./Datasets/falsification_lower_silesia.csv")
## OLS
m_strikes_ols <- lm(scale(strikes) ~ dist_closest_priest, data = data)
summary(m_strikes_ols)
rm(list =ls())
options(scipen=999)
gc()
packages <-c("tidyverse","estimatr","plm","stargazer",
"fastDummies","ICCbin","ihs","readstata13","xtable")
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(packages, require, character.only = TRUE)
rm(packages)
data <- read.csv("./Datasets/main_confounders.csv")
data <- data%>%
dplyr::mutate(strikes = scale(strikes),
strikes_1970 = scale(strikes_1970))
lm_strikes <- lm(strikes ~ strikes_1970, data = data)
summary(lm_strikes)
stargazer(lm_strikes,
dep.var.labels = c("Protests in the 1980s",),
style = "qje",
covariate.labels = c("Protests in the 1970s"),
star.char = c("*", "**", "***"),
star.cutoffs = c(0.1, 0.05, 0.01),
omit = c("Constant", "factor"),
omit.stat = c("rsq", "f", "ser"),
omit.table.layout = "n",
add.lines = list(c("Fixed effects", "No"),
c("Controls", "No")),
out = "PUT YOUR FILEPATH HERE")
stargazer(lm_strikes,
dep.var.labels = c("Protests in the 1980s"),
style = "qje",
covariate.labels = c("Protests in the 1970s"),
star.char = c("*", "**", "***"),
star.cutoffs = c(0.1, 0.05, 0.01),
omit = c("Constant", "factor"),
omit.stat = c("rsq", "f", "ser"),
omit.table.layout = "n",
add.lines = list(c("Fixed effects", "No"),
c("Controls", "No")),
out = "PUT YOUR FILEPATH HERE")
rm(list =ls())
options(scipen=999)
gc()
packages <-c("tidyverse","estimatr","plm","stargazer",
"fastDummies","ICCbin","ihs","readstata13","xtable")
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(packages, require, character.only = TRUE)
rm(packages)
data <- read.csv("./Datasets/main_confounders.csv")
data <- data%>%
dplyr::rowwise()%>%
dplyr::mutate(commander_1975_79 = mean(c(commanders1975, commanders1976,
commanders1977, commanders1978,
commanders1979), na.rm = TRUE))%>%
dplyr::ungroup()%>%
dplyr::mutate(commander_1975_79 = scale(commander_1975_79),
strikes_1970 = scale(strikes_1970))
lm_strikes <- lm(strikes_1970 ~ commander_1975_79, data = data)
summary(lm_strikes)
stargazer(lm_strikes,
dep.var.labels = c("Protests in the 1970s"),
style = "qje",
covariate.labels = c("Surveilance"),
star.char = c("*", "**", "***"),
star.cutoffs = c(0.1, 0.05, 0.01),
omit = c("Constant", "factor"),
omit.stat = c("rsq", "f", "ser"),
omit.table.layout = "n",
add.lines = list(c("Fixed effects", "No"),
c("Controls", "No")),
out = "PUT YOUR FILEPATH HERE")
rm(list =ls())
options(scipen=999)
gc()
packages <-c("tidyverse","estimatr","plm","stargazer",
"fastDummies","ICCbin","ihs","readstata13","xtable")
new.packages <- packages[!(packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(packages, require, character.only = TRUE)
rm(packages)
setwd("C:/Users/ttiet/Desktop/replication")
data <- read.csv("./Datasets/us_generalizability.csv")
data <- data%>%
dplyr::mutate(NSZZ_members_1981_capita = NSZZ_members_1981/Pop_1980,
Investmens_1976_80_capita = Investments_1976_80/((Pop_1975 + Pop_1980)/2),
Employed_industry_1975_capita = Employed_industry_1975/Pop_1975,
Emploýed_industry_1980_capita = Employed_industry_1980/Pop_1980,
Employed_agricult_1975_capita = Employed_agricult_1975/Pop_1975,
Employed_agricult_1980_capita = Employed_agricult_1980/Pop_1980,
Migr_ratio_urban_1975_capita = Migr_ratio_urban_1975/Pop_1975,
Migr_ratio_urban_1980_capita = Migr_ratio_urban_1980/Pop_1980,
Migr_ratio_rural_1975_capita = Migr_ratio_rural_1975/Pop_1975,
Migr_ratio_rural_1980_capita = Migr_ratio_rural_1980/Pop_1980,
Urban_pop_1975_capita = Urban_pop_1975/Pop_1975,
Urban_pop_1980_capita = Urban_pop_1980/Pop_1980,
Rural_pop_1975_capita = Rural_pop_1975/Pop_1975,
Rural_pop_1980_capita = Rural_pop_1980/Pop_1980,
Pwnaionwe_1980_capita = Pensioners_1980/Pop_1980,
US = c(1,1,1,1,0),
SB_1975_capita = SB_1975/(Pop_1975/1000),
SB_1976_capita = SB_1976/(Pop_1975/1000),
SB_1977_capita = SB_1977/(Pop_1975/1000),
SB_1978_capita = SB_1978/(Pop_1975/1000),
SB_1979_capita = SB_1979/(Pop_1975/1000),
SB_1980_capita = SB_1980/(Pop_1980/1000),
SB_1981_capita = SB_1981/(Pop_1980/1000),
SB_1982_capita = SB_1982/(Pop_1980/1000),
SB_1983_capita = SB_1983/(Pop_1980/1000),
SB_1984_capita = SB_1984/(Pop_1980/1000))
vars <- c("Average_salary_1980",colnames(data)[c(31:45,47:56)])
means_poland <- data%>%
dplyr::filter(., US == 0)%>%
dplyr::summarise_at(vars, mean, na.rm = TRUE)
means_upper_silesia <- data%>%
dplyr::filter(., US == 1)%>%
dplyr::summarise_at(vars, mean, na.rm = TRUE)
View(means_upper_silesia)
stargazer(means_poland)
stargazer(means_poland, means_upper_silesia)
